<%@ page import="comoabejas.Deal" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'deal.label', default: 'Deal')}" />
        <title><g:message code="default.create.label" args="[entityName]" /></title>
        <tinyMce:importJs toolbarPosition="bottom"/>
    </head>
    <body>
		<calendar:resources lang="en" theme="tiger"/>  
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.create.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${dealInstance}">
            <div class="errors">
                <g:renderErrors bean="${dealInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form action="save" enctype="multipart/form-data" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="address"><g:message code="deal.address.label" default="Address" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'address', 'errors')}">
                                    <g:textField name="address" value="${dealInstance?.address}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="area"><g:message code="deal.area.label" default="Area" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'area', 'errors')}">
                                    <g:select name="area.id" from="${comoabejas.Area.list()}" optionValue="name" optionKey="id" value="${dealInstance?.area?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="client"><g:message code="deal.client.label" default="Client" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'client', 'errors')}">
                                    <g:select name="client.id" from="${comoabejas.Client.list()}" optionValue="companyName" optionKey="id" value="${dealInstance?.client?.id}"  />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="title"><g:message code="deal.title.label" default="Title" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'title', 'errors')}">
<!--                                    <g:textField name="title" value="${dealInstance?.title}" />-->
                                    <tinyMce:renderEditor type="advanced" name="title" value="${dealInstance?.title?.encodeAsHTML()}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="conditions"><g:message code="deal.conditions.label" default="Conditions" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'conditions', 'errors')}">
<!--                                    <g:textField name="conditions" value="${dealInstance?.conditions}" />-->
                                    <tinyMce:renderEditor type="advanced" name="conditions" value="${dealInstance?.conditions?.encodeAsHTML()}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description"><g:message code="deal.description.label" default="Description" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'description', 'errors')}">
<!--                                    <g:textArea name="description" value="${dealInstance?.description}" />-->
                                    <tinyMce:renderEditor type="advanced" name="description" value="${dealInstance?.description?.encodeAsHTML()}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="details"><g:message code="deal.details.label" default="Details" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'details', 'errors')}">
<!--                                    <g:textArea name="details" value="${dealInstance?.details}" />-->
                                    <tinyMce:renderEditor type="advanced" name="details" value="${dealInstance?.details?.encodeAsHTML()}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="normalPrice"><g:message code="deal.normalPrice.label" default="Normal Price" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'normalPrice', 'errors')}">
                                    <g:textField name="normalPrice" value="${fieldValue(bean: dealInstance, field: 'normalPrice')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="discountPrice"><g:message code="deal.discountPrice.label" default="Discount Price" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'discountPrice', 'errors')}">
                                    <g:textField name="discountPrice" value="${fieldValue(bean: dealInstance, field: 'discountPrice')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="startDate"><g:message code="deal.startDate.label" default="Start Date" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'startDate', 'errors')}">
									<calendar:datePicker name="startDate" lang="en" value="${dealInstance?.endDate}" dateFormat="%d/%m/%Y"/>
									<!-- 
                                    <g:datePicker name="startDate" precision="minute" value="${dealInstance?.startDate}"  />
									 -->                                
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="endDate"><g:message code="deal.endDate.label" default="End Date" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'endDate', 'errors')}">
									<calendar:datePicker name="endDate" lang="en" value="${dealInstance?.endDate}" dateFormat="%d/%m/%Y"/>
                                	<!-- 
                                    <g:datePicker name="endDate" precision="minute" value="${dealInstance?.endDate}"  />
                                	 -->
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="imageLink"><g:message code="deal.imageLink.label" default="Image Link" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'imageLink', 'errors')}">
<!--                                    <g:textField name="imageLink" value="${dealInstance?.imageLink}" />-->
									<input type="file" name="myFile" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="requiredNumberOfUsers"><g:message code="deal.requiredNumberOfUsers.label" default="Required Number Of Users" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'requiredNumberOfUsers', 'errors')}">
                                    <g:textField name="requiredNumberOfUsers" value="${fieldValue(bean: dealInstance, field: 'requiredNumberOfUsers')}" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="voucherStartDate"><g:message code="deal.voucherStartDate.label" default="Voucher Start Date" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'voucherStartDate', 'errors')}">
									<calendar:datePicker name="voucherStartDate" lang="en" value="${dealInstance?.voucherStartDate}" dateFormat="%d/%m/%Y"/>
									<!-- 
                                    <g:datePicker name="voucherStartDate" precision="day" value="${dealInstance?.voucherStartDate}"  />
									 -->                                
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="voucherEndDate"><g:message code="deal.voucherEndDate.label" default="Voucher End Date" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: dealInstance, field: 'voucherEndDate', 'errors')}">
                                <!-- 
                                    <g:datePicker name="voucherEndDate" precision="day" value="${dealInstance?.voucherEndDate}"  />
                                 -->
									<calendar:datePicker name="voucherEndDate" lang="en" value="${dealInstance?.voucherEndDate}" dateFormat="%d/%m/%Y"/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
